/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.com.actionsystem.gdp.dao;

import br.com.actionsystem.gdp.modelo.Categoria;
import br.com.actionsystem.gdp.util.DaoException;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;


/**
 *
 * @author aluno
 */
public class CategoriaDaoImpl implements IntCategoriaDao{
        EntityManager em;
        Query q;
    public List<Categoria> listarTodas() throws DaoException {
        try {
           em = ConexaoSingleton.getConexao();
            q = em.createQuery("from Categoria");
        return q.getResultList();
        } catch (Exception e) {
            throw  new DaoException("não foi possivel acessar os dados", e);
           
        }

    }

    public void salvar(Categoria c) {
       em.getTransaction().begin();
       em.persist(c);
       em.flush();
       em.getTransaction().commit();
     }
        }

